package com.hzhjhh.view.manageView.menus.purchase.payment;

import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import com.hzhjhh.init.dialog.Mytable;
import com.hzhjhh.view.manageView.menus.purchase.PaymentOrderDialog;

/**
 * 菜单栏初始化-采购-付款单弹出框-删除按钮
 * 
 * @author 12083
 *
 */
public class DeleteBt {

	/**
	 * 按钮
	 */
	public static JButton btInit(PaymentOrderDialog paymentOrderDialog) {
		JButton delete = new JButton();
		delete.setBounds(500, 376, 80, 35);
        delete.setText("删   除");
        delete.addActionListener(event -> {
        	JTable jTable1 = paymentOrderDialog.getJTable1();
        	Vector colnames4 = paymentOrderDialog.getRowDatas();
        	Vector colnames = paymentOrderDialog.getColnames();
        	JScrollPane jScrollPane1 = paymentOrderDialog.getJScrollPane1();
        	
        	int row = jTable1.getSelectedRow();
        	if (row < 0) {
        		JOptionPane.showMessageDialog(paymentOrderDialog, "没有选择删除数据，请选择数据后执行删除操作", "提示", JOptionPane.INFORMATION_MESSAGE);
        		return;
			}
    		colnames4.remove(row);
    		jTable1 = Mytable.maketable(colnames4, colnames); // 显示内容
    		jScrollPane1.getViewport().add(jTable1); // 把表装入容器
        });
		return delete;
	}
}
